package com.weirong.smartvault.dao;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.weirong.smartvault.entity.UserLoginLog;

@Repository
@Qualifier("userLoginLogRepository")
public interface UserLoginLogRepository extends JpaRepository<UserLoginLog, Integer>{

    @Query("SELECT loginUser FROM UserLoginLog loginUser WHERE loginUser.loginTime >= :beginDate and loginUser.loginTime <= :endDate and loginUser.type = :type ORDER BY loginTime DESC")
    public List<UserLoginLog> findCurrentLoginUser(@Param("beginDate") Timestamp beginDate, @Param("endDate") Timestamp endDate, @Param("type") String type);
    
    @Query("SELECT loginUser FROM UserLoginLog loginUser WHERE loginUser.type = :type ORDER BY loginTime DESC")
    public List<UserLoginLog> findAllLoginUser(@Param("type") String type);
}
